class_name Skill_Modifier_OperationProp
extends SkillModifier

## 对已有属性做指定类型的运算

enum OperationType
{
	Add,
	Sub,
	Mul,
	Div, # val作除数
	InDiv, # val作被除数
}
#region 属性
@export var prop_dict:Dictionary
@export var operation_type:OperationType
@export var val:float
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
func modify(args:Array = []):
	var target = args[0]
	for key in prop_dict.keys():
		if key in target:
			var t = typeof(target[key])
			if t != TYPE_INT and t != TYPE_FLOAT:
				continue
			if operation_type == OperationType.Add:
				target[key] += val
			elif operation_type == OperationType.Sub:
				target[key] -= val
			elif operation_type == OperationType.Mul:
				target[key] *= val
			elif operation_type == OperationType.Div:
				if val != 0:
					target[key] /= val
			elif operation_type == OperationType.InDiv:
				if target[key] != 0:
					target[key] = val / target[key]
func inmodify(args:Array = []):
	var target = args[0]
	for key in prop_dict.keys():
		if key in target:
			var t = typeof(target[key])
			if t != TYPE_INT and t != TYPE_FLOAT:
				continue
			if operation_type == OperationType.Add:
				target[key] -= val
			elif operation_type == OperationType.Sub:
				target[key] += val
			elif operation_type == OperationType.Mul:
				if val != 0:
					target[key] /= val
			elif operation_type == OperationType.Div:
				target[key] *= val
			elif operation_type == OperationType.InDiv:
				if val != 0:
					target[key] /= val
#endregion
#region 公共方法
#endregion
#region 私有方法
#endregion
#region 生命周期函数
#endregion
